{include file="public/layout" /}
<body class="laytp-container">
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form layui-row layui-col-space16 layui-search-admin">
            <div class="layui-inline">
                <label class="layui-form-label">会员ID</label>
                <div class="layui-input-inline" >
                    <input type="text" name="user_id" value="" placeholder="会员ID" class="layui-input" lay-affix="clear">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">会员编号</label>
                <div class="layui-input-inline" >
                    <input type="text" name="username" placeholder="会员编号" lay-affix="clear" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">推广人</label>
                <div class="layui-input-inline" >
                    <input type="text" name="tjr_name" placeholder="推广人" lay-affix="clear" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width: 100px;">选择会员级别</label>
                <div class="layui-input-inline">
                    <select name="level">
                        <option value="">选择会员级别</option>
                        {foreach $level_arr as $level}
                            <option value="{$level.rank}">{$level.level_name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">注册日期</label>
                <div class="layui-inline" id="laydate-rangeLinked">
                    <div class="layui-input-inline">
                        <input type="text" name="time_start" autocomplete="off" id="table-search-date-start" class="layui-input" placeholder="开始日期">
                    </div>-
                    <div class="layui-input-inline">
                        <input type="text" name="time_end" autocomplete="off" id="table-search-date-end" class="layui-input" placeholder="结束日期">
                    </div>
                </div>
            </div>

            <div class="layui-btn-container layui-col-xs12">
                <button class="layui-btn" lay-submit lay-filter="demo-table-search">搜索</button>
                <button type="reset" class="layui-btn layui-btn-primary">清空</button>
            </div>
        </form>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-body">
        <table id="test" lay-filter="test"></table>
    </div>
</div>
<div id="sendModel" style="width:500px;display:none;margin-top:30px">
    <div class="layui-form form-label-w6" lay-filter="">
        <input type="hidden" name="cpid" value="{$coupon.id}"/>
        <input type="hidden" name="sendtype" id="sendtype" value="0"/>
        <div class="layui-form-item">
            <label class="layui-form-label">{:t('优惠券')}名称：</label>
            <div class="layui-form-mid" style="color:#000">{$coupon.name}</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">每人发送数量：</label>
            <div class="layui-input-inline" style="width:100px">
                <input type="text" name="persendnum" id="persendnum" value="1" lay-verify="required" lay-verType="tips" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">共计发送人数：</label>
            <div class="layui-form-mid" id="sendnum">0</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="formsend">发送</button>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" onclick="reload()">
            刷新数据
        </button>
    </div>
</script>
<script type="text/html" id="barDemo">
    <div class="layui-clear-space">
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<!--        <a class="layui-btn layui-btn-xs" lay-event="recharge">充值</a>-->
        <a class="layui-btn layui-btn-xs" lay-event="more">
            更多
            <i class="layui-icon layui-icon-down"></i>
        </a>
    </div>
</script>
<script>
    var tableIns
    var datawhere = {};
    layui.use(function(){
        var table = layui.table;
        var dropdown = layui.dropdown;
        var laydate = layui.laydate;
        var form = layui.form;

        // 创建渲染实例
        tableIns = table.render({
            elem: '#test',
            url:'{:url("index")}', // 此处为静态模拟数据，实际使用时需换成真实接口
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter'],
            height: 'full-200', // 最大高度减去其他容器已占有的高度差
            css: [ // 重设当前表格样式
                '.layui-table-tool-temp{padding-right: 145px;}'
            ].join(''),
            cellMinWidth: 80,
            totalRow: true, // 开启合计行
            page: true,
            pagebar: '#test-pagebar', // 分页栏模板
            cols: [[
                {type: 'checkbox', fixed: 'left'},
                {field:'user_id', fixed: 'left', width:80, title: 'ID', sort: true, totalRowText: '合计：'},
                {field:'username', width:80, title: '会员编号',totalRowText: ''},
                {field:'nickname', title:'姓名',  width:150},
                {field:'level_name', width:80, title: '会员级别'},
                {field:'mobile', title: '手机号'},
                {field:'tjr_name', width: 100, title: '推广人'},
                {field:'gl_username', title:'管理人', width: 100},
                {field:'reg_time', title:'注册时间'},
                // {field: 'reg_time', title: '注册时间',sort: true,templet:function(d){ return date('Y-m-d H:i',d.reg_time)}},
                {field:'money', width:80, title: '余额', sort: true,totalRow: '{{=d.TOTAL_ROW.money_total}}'},
                {field:'score', width:80, title: '积分', sort: true,totalRow: '{{=d.TOTAL_ROW.score_total}}'},
                {fixed: 'right', title:'操作', width: 134, minWidth: 125, templet: '<div><button class="layui-btn layui-btn-sm" onclick="chooseuser(\'{{d.id}}\')">选择</button></div>'}
            ]],
            error: function(res, msg){
                console.log(res, msg)
            }
        });

        laydate.render({
            elem: '.demo-table-search-date'
        });
        laydate.render({
            elem: '#laydate-rangeLinked',
            type: 'datetime',
            range: ['#table-search-date-start', '#table-search-date-end'],
            rangeLinked: true // 开启日期范围选择时的区间联动标注模式 ---  2.8+ 新增
        });
        // 搜索提交
        form.on('submit(demo-table-search)', function(data){
            var field = data.field; // 获得表单字段
            datawhere = field;
            // 执行搜索重载
            table.reload('test', {
                page: {
                    curr: 1 // 重新从第 1 页开始
                },
                where: field // 搜索的字段
            });
            //layer.msg('搜索成功<br>此处为静态模拟数据，实际使用时换成真实接口即可');
            return false; // 阻止默认 form 跳转
        });
    });
</script>
</body>
</html>